import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import rem2px from 'postcss-rem-to-responsive-pixel'
import { UnifiedViteWeappTailwindcssPlugin as uvtw } from 'weapp-tailwindcss/vite'
import tailwindcss from 'tailwindcss'
import autoprefixer from 'autoprefixer'
const isH5 = process.env.UNI_PLATFORM === 'h5'
const isApp = process.env.UNI_PLATFORM === 'app-plus'
const WeappTailwindcssDisabled = isH5 || isApp

const postcssPlugins = [tailwindcss(), autoprefixer()]

if (!WeappTailwindcssDisabled) {
  postcssPlugins.push(
    rem2px({
      rootValue: 32,
      propList: ['*'],
      transformUnit: 'rpx'
    })
  )
}


// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
  ],
  css: {
    postcss: {
      plugins: postcssPlugins
    }
  }
})
